package cn.yjr.fragment;

import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;
import cn.edu.pku.tools.FileHelper;
import cn.edu.pku.tools.SharedPreferencesHelper;
import cn.edu.pku.tools.YJRApplication;
import cn.liuyi.weiyi.R;

import com.actionbarsherlock.app.SherlockFragment;

/**
 * @author vector
 *
 */
@SuppressLint("ValidFragment")
public class BaseInfoFragment extends SherlockFragment {
	View view;
	Context context;
	JSONObject doctor;
	SharedPreferencesHelper helper;
	String name =null;
	String hospital = null;
	String head = null;
	String category = null;
	String section = null;
	String title = null;
	String title_name = null;
	boolean recommend = false;
	String groupIntro;
	String notice, skills, type;
	TextView hospital_tv, dpt_tv, title_tv, team_info_tv;
	@SuppressLint("ValidFragment")
	public BaseInfoFragment(JSONObject data){
		doctor = data;
		try {
			name = doctor.getString("name");
			hospital = doctor.getJSONObject("hospital").getString("name");
			head = doctor.getString("avatar");
			category = doctor.getString("category");
			recommend = doctor.getBoolean("recommend");
			section = doctor.getJSONObject("section").getString("text");
			groupIntro = doctor.getString("groupIntro");
			title = doctor.getString("title");
			notice = doctor.getString("notice");
			skills = doctor.getString("skills");
			type = doctor.getString("type");
			//title_name = YJRApplication.initData.getJSONObject("codings").getJSONObject("doctoryCategory").getJSONObject(category).getJSONObject("title").getString(title);
			title_name = YJRApplication.initData.getJSONObject("codings").getJSONObject("doctorCategory").getJSONObject(category).getJSONObject("title").getString(title);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
	}
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    	view = inflater.inflate(R.layout.base_info,container, false);
	    this.context = getActivity();
	    this.helper = new SharedPreferencesHelper(this.context);
	    hospital_tv = (TextView) view.findViewById(R.id.hospital_tv);
	    dpt_tv = (TextView) view.findViewById(R.id.dpt_tv);
	    title_tv = (TextView) view.findViewById(R.id.title_tv);
	    team_info_tv = (TextView) view.findViewById(R.id.team_info_tv);
	    hospital_tv.setText(hospital);;
	    dpt_tv.setText(section);
	    title_tv.setText(title_name);
	    team_info_tv.setText(groupIntro);
	    return this.view;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }
}
